import pandas as pd
from examples.example_9_wide_resource_spacing_multiple.ex_9_model_classes import g, Trial
from vidigi.animation import animate_activity_log
import plotly.io as pio
pio.renderers.default = "notebook"Creative Layouts - Multiple Ward Example
clinic_simulation = Trial()clinic_simulation.trial_results| entity_id | event_type | event | time | pathway | run_number | timestamp | resource_id | |
|---|---|---|---|---|---|---|---|---|
| 0 | 1 | arrival_departure | arrival | 0.000000 | None | 1 | None | NaN |
| 1 | 1 | queue | bed_wait_begins | 0.000000 | None | 1 | None | NaN |
| 2 | 1 | resource_use | maple_stay_begins | 0.000000 | None | 1 | None | 1.0 |
| 3 | 2 | arrival_departure | arrival | 0.519445 | None | 1 | None | NaN |
| 4 | 2 | queue | bed_wait_begins | 0.519445 | None | 1 | None | NaN |
| ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 10272 | 2143 | arrival_departure | arrival | 8735.445825 | None | 100 | None | NaN |
| 10273 | 2143 | queue | bed_wait_begins | 8735.445825 | None | 100 | None | NaN |
| 10274 | 2144 | arrival_departure | arrival | 8735.740369 | None | 100 | None | NaN |
| 10275 | 2144 | queue | bed_wait_begins | 8735.740369 | None | 100 | None | NaN |
| 10276 | 2144 | resource_use | maple_stay_begins | 8735.740369 | None | 100 | None | 8.0 |
1050654 rows × 8 columns
event_position_df = pd.DataFrame([
{'event': 'arrival',
'x': 50, 'y': 800,
'label': "Arrival" },
# Triage - minor and trauma
{'event': 'bed_wait_begins',
'x': 505, 'y': 700,
'label': "Waiting for Bed"},
{'event': 'ash_stay_begins',
'x': 675, 'y': 275,
'resource':'number_of_beds_ash',
'label': "Ash Ward"},
{'event': 'oak_stay_begins',
'x': 205, 'y': 475,
'resource':'number_of_beds_oak',
'label': "Oak Ward"},
{'event': 'maple_stay_begins',
'x': 205, 'y': 175,
'resource':'number_of_beds_maple',
'label': "Maple Ward"},
{'event': 'depart',
'x': 740, 'y': 70,
'label': "Exit"}
])animate_activity_log(
event_log=clinic_simulation.trial_results[clinic_simulation.trial_results['run_number']==1],
event_position_df= event_position_df,
scenario=g(),
# Key animation prep parameters
every_x_time_units=3,
simulation_time_unit="hours",
limit_duration=g.sim_duration,
step_snapshot_max=125,
# Animation display parameters
time_display_units="dhm",
include_play_button=True,
setup_mode=False,
debug_mode=True,
frame_duration=500,
# Text parameters
display_stage_labels=True,
text_size=20,
# Entity and queue size and spacing
entity_icon_size=16,
wrap_queues_at=25,
gap_between_entities=12,
gap_between_queue_rows=30,
# Resource size and spacing
gap_between_resources=80,
gap_between_resource_rows=40,
resource_icon_size=25,
wrap_resources_at=2,
custom_resource_icon='🛏️',
custom_entity_icon_list=['🧍'],
# Plot size
plotly_height=900,
plotly_width=1200,
# Internal plot coordinates
override_x_max=800,
override_y_max=900,
)Animation function called at 15:41:32
Iteration through time-unit-by-time-unit logs complete 15:41:49
Snapshot df concatenation complete at 15:41:50
Reshaped animation dataframe finished construction at 15:41:51
Placement dataframe finished construction at 15:41:51
Output animation generation complete at 15:42:06
Total Time Elapsed: 34.02 seconds